package com.cnap.model.strategy.schedule;

import cn.hutool.core.text.CharSequenceUtil;

/**
 * <类文件描述>
 *
 * @author xc
 **/
public enum PolicyEnum {
    // 负载
    LOAD("load balancing", "负载感知调度策略"),
    // 成本
    COST("price", "成本感知调度策略"),
    // sla
    SLA("sla", "SLA感知调度策略"),
    // energy
    ENERGY("energy", "能耗感知调度策略"),
    // unknown
    UNKNOWN("unknown", "未知策略"),
    ;
    private final String enName;
    private final String chName;

    PolicyEnum(String enName, String chName) {
        this.enName = enName;
        this.chName = chName;
    }

    /**
     * get
     *
     * @return EnName
     */
    public String getEnName() {
        return enName;
    }

    /**
     * get
     *
     * @return ChName
     */
    public String getChName() {
        return chName;
    }

    /**
     * 根据中文名称查询英文名称
     *
     * @param chName 中文名称
     * @return 结果
     */
    public static String getEnNameFromChName(String chName) {
        PolicyEnum[] policyEnums = PolicyEnum.values();
        if (CharSequenceUtil.isEmpty(chName)) {
            return UNKNOWN.getEnName();
        }
        for (PolicyEnum policyEnum : policyEnums) {
            if (policyEnum.getChName().equals(chName)) {
                return policyEnum.getEnName();
            }
        }
        return UNKNOWN.getEnName();
    }
}
